package com.lzy.liujing.restaurant.dao;

import com.lzy.liujing.restaurant.entity.SysUser;
import org.apache.ibatis.annotations.*;
import org.apache.shiro.authc.Account;

import java.awt.print.Book;
import java.lang.annotation.Inherited;
import java.util.List;

@Mapper
public interface SysUserDao{

    @Select("select * from sys_user")
    List<SysUser> selectAll();

    @Select("<script> SELECT * from sys_user" +
            "<where>"+
            "<if test='loginCode != null'>and login_code = #{loginCode}</if> "+
            " <if test='name != null'>and name = #{name}</if> "+
            " <if test='gender != null'>and gender = #{gender}</if> " +
            "</where>"+
            "</script>")
    List<SysUser> findPage(SysUser query);

    @Select("select * from sys_user where login_code=#{loginCode}")
    SysUser selectByName(String username);

    @Delete("delete from sys_user where user_id =#{user_id}")
    int delete(Integer id);
    // insert 一条记录
    @Insert("insert into sys_user (login_code, password, name, phone, email, gender, birthday, id_number, address) values(#{loginCode},#{password},#{name}," +
            " #{phone},#{email},#{gender}, #{birthday}, #{idNumber}, #{address})")
    int insert(SysUser brand);
    // 修改 brand记录
    @Update("update sys_user set login_code = #{loginCode}, password = #{password}," +
            " name = #{name}, phone = #{phone}, email = #{email}, gender = #{gender}," +
            " birthday = #{birthday}, id_number = #{idNumber}, address = #{address} where user_id = #{userId}")
    int update(SysUser brand);
    // 批量删除 记录

    @Select("SELECT * FROM sys_user WHERE user_id = #{userId}")
    SysUser getById(Integer id);


}
